﻿using EasyAdmin.Application.Contracts.Systems.EndpointLogs;
using EasyAdmin.Domain.Entities.Systems;
using EasyCore.Application;
using EasyCore.EndpointAudits;
using EasyCore.ObjectMapper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyAdmin.Application.Systems
{
    public class EndpointLogAppService : AppService, IEndpointAuditHandler, IEndpointLogAppService
    {
        private readonly ISqlSugarRepository<SysAuditLog> _endpointLogRepao;

        public EndpointLogAppService(ISqlSugarRepository<SysAuditLog> endpointLogRepao)
        {
            _endpointLogRepao = endpointLogRepao;
        }

        public async Task HandleAsync(EndpointAuditResult input)
        {
            var model = input.MapTo<SysAuditLog>();
            await _endpointLogRepao.InsertAsync(model);
        }
    }
}
